Skip to content

Address review feedback on persisted history copy - #1799

Merged
tleonhardt merged 1 commit into
mainfrom
tidy/persist-history-review
Oct 31, 2026
Merged

tleonhardt merged 1 commit into
mainfrom
tidy/persist-history-review

Conversation

@tleonhardt

Copy link
Copy Markdown
Member

Summary

Follow-up to #1796, applying three review comments that were left before it merged. No behavior change.

  • Explain the copy (comment): _persist_history() now has a comment saying why it truncates a copy, so it isn't later simplified back into truncating the live history.
  • Trim the tests (review):
    • Removed test_persist_history_no_file_preserves_live_state (couldn't fail and duplicated test_persist_history_ensure_no_error_if_no_histfile), test_persist_history_empty (passed with the fix reverted) and test_persist_history_write_error_preserves_live_state.
    • In place of the write-error test, test_persist_history_permission_error now checks that live history is unchanged. It sets a limit shorter than the history so that check can actually fail.
    • Dropped the reload and prompt-toolkit half of the repeat/append test, which test_history_populates_pt already covers, and renamed it test_persist_history_repeat_and_append.
    • Kept the parametrized test_persist_history_preserves_live_state as is.
  • Helper nits (comment): read_persisted_history imports lzma directly; History joins the module-level cmd2.history import; history_state no longer compares span(":") or str_search("third").

Net change: +29 / −74 lines.

Validation

  • With the Preserve live history while persisting a bounded copy #1796 fix temporarily reverted, 6 of the 9 remaining history-saving tests fail, including the updated permission-error test. The 3 that pass are the no-histfile test and the limit 4 and 6 cases, as expected.
  • make check, make test (2931 passed, 3 skipped) and make docs-test pass.

No CHANGELOG entry, since only a comment and tests changed.

Follow-up to #1796, applying review comments made before it merged.

Comment why _persist_history() truncates a copy, so it is not later
simplified back into truncating the live history.

Trim the new tests. Drop the no-file, empty-history, and write-error
cases, which either could not fail or duplicated existing tests, and
instead assert unchanged live state in the existing permission-error
test with a limit shorter than the history. Drop the reload half of the
repeat/append test, which re-tested loading.

Simplify the helpers: import lzma directly, move the History import to
module level, and stop comparing span and search results that follow
from the item identities and session boundary already compared.
@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.75%. Comparing base (07a8f56) to head (9da34b2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1799   +/-   ##
=======================================
  Coverage   99.75%   99.75%           
=======================================
  Files          23       23           
  Lines        6593     6593           
=======================================
  Hits         6577     6577           
  Misses         16       16           
Flag Coverage Δ
unittests 99.75% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@tleonhardt
tleonhardt merged commit afc0612 into main Oct 31, 2026
32 checks passed
@tleonhardt
tleonhardt deleted the tidy/persist-history-review branch October 31, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant